package com.peanut.sql.lineage.postgresql;

import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/****
 author:yifan
 date:2016
 description:
 **/
public class Column extends Vertex {
    private String columnName;
    private String columnComment;
    private String columnType;
    private String tableName;
    private String schemaName;
    private String databaseName;

    public Column(String columnName, String columnComment, String columnType, String tableName, String schemaName, String databaseName) {
        this.columnName = columnName;
        this.columnComment = columnComment;
        this.columnType = columnType;
        this.tableName = tableName;
        this.schemaName = schemaName;
        this.databaseName = databaseName;
    }

    public Column() {
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnComment() {
        return columnComment;
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    public String getColumnType() {
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getSchemaName() {
        return schemaName;
    }

    public void setSchemaName(String schemaName) {
        this.schemaName = schemaName;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Column column = (Column) o;
        return Objects.equals(columnName, column.columnName) &&
                Objects.equals(columnComment, column.columnComment) &&
                Objects.equals(columnType, column.columnType) &&
                Objects.equals(tableName, column.tableName) &&
                Objects.equals(schemaName, column.schemaName) &&
                Objects.equals(databaseName, column.databaseName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(columnName, columnComment, columnType, tableName, schemaName, databaseName);
    }

    @Override
    public String toString() {
        return StringUtils.join(new String[]{schemaName, tableName, columnName}, ".");
    }
}
